package com.maxmlr.music.common.bean;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class ResultPageBean<T> extends ResultBean<T> {
    private static final long serialVersionUID = 1L;

    private PageBean page;

    private List<T> list;

    public ResultPageBean(List<T> list, Page<?> page) {
        this.list = list;
        this.page = new PageBean(page);
    }

    public static <T> ResultPageBean<T> ok(Page<T> page) {
        return new ResultPageBean<>(page.getRecords(), page);
    }

    public static <T> ResultPageBean<T> ok(List<T> list, Page<?> page) {
        return new ResultPageBean<>(list, page);
    }

}
